#region usings

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Drawing.Imaging;


using CStock;
using CUtil;
using CTrading;

using System.Threading;
using CGraph;

using EForms;
using System.Collections.Generic;
#endregion


namespace CapitalReSources
{
	/// <summary>
	/// Summary description for MainClass
	/// </summary>
	public partial class MainClass : IMainClass
	{
		#region fields

		private IView view;
		protected DataGridClass dataGridClass ;
		private IProgramContext programContext;
		private ITreeViewStock treeViewStock;
        private ITreeViewStock treeViewCustomPortfolios;
		
        private IGrid gridDataView ;
        private IGrid gridStockData;
        private IGrid gridTrade;
        private IGridIntraday gridIntraday;
        private IGridFundamentalData gridFundamentalData;
       
        private PropertyGrid propertyGrid;
		private IListViewShareData listViewShareData;
		private ITabControlStock tabControlStock ;
		private ITradeControl tradeControl;

		
		private IListViewIntraday listViewIntraday;

		

		

		
		private static MainClass instance;

		
		private System.Collections.ArrayList chartWindows;
		private System.Collections.ArrayList chartWindowsShare;
        

        private bool updateWebFinished;
        private QuoteUpdater quoteUpdater;
        WebYahooIntraday yahooIntraday;
        private string webupdate_IntradayPortfolioName = "Webupdate_Intraday_FetchList";
        IPortfolio portfolioWebUpdate;
        bool customPortfolioTreeViewActive;

		#endregion

		#region properties

		public static MainClass Instance
		{
			get
			{
				return MainClass.instance;
			}
		}
        public IProgramContext ProgramContext
        {
            get
            {
                return this.programContext;
            }
            set
            {
                programContext = value;
            }
        }
		public IView View
		{
			get
			{
				return this.view;
			}
			set
			{
				view = value;
				
			}
		}

		public IGrid GridDataView 
		{
			get
			{
				return this.gridDataView;
			}
			set
			{
				gridDataView = value;
			}
		}
        public IGrid GridStockData 
		{
			get
			{
                return this.gridStockData;
			}
			set
			{
                gridStockData = value;
			}
		}
        

		public IListViewIntraday ListViewIntraday
		{
			get
			{
				return this.listViewIntraday;
			}
			set
			{
				listViewIntraday = value;
			}
		}
		public IGridIntraday GridIntraday
		{
			get
			{
				return this.gridIntraday;
			}
			set
			{
				gridIntraday = value;
			}
		}
        public IGridFundamentalData GridFundamentalData
		{
			get
			{
                return this.gridFundamentalData;
			}
			set
			{
                gridFundamentalData = value;
			}
		}
      
		public PropertyGrid PropertyGrid
		{
			get
			{
				return this.propertyGrid;
			}
			set
			{
				this.propertyGrid = value;
			}
		}
		public ITreeViewStock TreeViewStock 
		{
			get
			{
				return this.treeViewStock;
			}
			set
			{
				this.treeViewStock = value;
			}
		}
        public ITreeViewStock TreeViewCustomPortfolios 
		{
			get
			{
                return this.treeViewCustomPortfolios;
			}
			set
			{
                this.treeViewCustomPortfolios = value;
			}
		}
        

		public IGrid GridTrade
		{
			get
			{
				return this.gridTrade;
			}
			set
			{
				this.gridTrade = value;
                DoTradeSystemBuySell();
			}
		}
	
		public IListViewShareData ListViewShareData
		{
			get
			{
				return this.listViewShareData;
			}
			set
			{
				this.listViewShareData = value;
			}
		}

        public bool CustomPortfolioTreeViewActive
        {
            get
            {
                return this.customPortfolioTreeViewActive;
            }
            set
            {
                customPortfolioTreeViewActive = value;
            }
        }

		public ITabControlStock TabControlStock 
		{
			get
			{
				return this.tabControlStock;
			}
			set
			{
				this.tabControlStock = value;
			}


		}
		public ITradeControl TradeControl
		{
			get
			{
				return this.tradeControl;
			}
			set
			{
				this.tradeControl = value;
			}


		}

        public QuoteUpdater QuoteUpdater
        {
            get
            {
                return this.quoteUpdater;
            }
        }

        private IPortfolio PortfolioWebUpdate
        {
            get
            {
                if (portfolioWebUpdate == null)
                    portfolioWebUpdate = GetPortfolioWebupdate();
                return portfolioWebUpdate;
            }
        }

		#endregion

	}
}
